var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
    //配置发送者的邮箱服务器和登录信息
    service: 'qq',//163、qq等
    auth: {
        user: '2205227953@qq.com',//邮箱
        pass: 'rtmqtksjrcreeceg'//邮箱密码或授权码
    }
});


const emailFn = ((email, res, num) => {

    var mailOptions = {
        from: '2205227953@qq.com',//发送者
        to: email,//接受者
        subject: '安国社保信息注册账号',//主题名
        text: '你好',//文本
        html: `
        <h2>好小子欢迎你加入“光之国！！！”  </h2>
        <div> 验证码为：${num} </div>
         `,//内容,
    }
    transporter.sendMail(mailOptions, function (err, info) {

        if (err) return res.send({ code: 300, msg: "请确定邮箱地址" })
        res.send({ code: 200, msg: "发送成功" })
    });
})
module.exports = emailFn